# -*- coding: utf-8 -*-
"""
Created on Fri Jul  7 17:37:30 2017

@author: hasee
"""

import logging
#log BEGIN
# 0-->ALL, 1 -->ERROR 
#_LOG_LEVEL=0 

    
#if platform.system() == 'Linux' :
#    _WINDOWS_FLAG=False
#else:
#    _WINDOWS_FLAG=True
#    sys.path.append("..\\..")
#    
#if _WINDOWS_FLAG == False :
#    logfile="../log/mqtt_log"
#else :
#    logfile="matt_log"# the function to set log file, SL:2014/10/3
    
def setlog(title,logfile) :
    
    logger = logging.getLogger(title)
    
    formatter = logging.Formatter('%(name)-12s %(asctime)s %(levelname)-8s %(message)s')    
    file_handler = logging.FileHandler(logfile) 
    #file_handler = TimedRotatingFileHandler(logfile,when="D")
    file_handler.setFormatter(formatter)        
    #stream_handler = logging.StreamHandler(sys.stderr) 
    logger.addHandler(file_handler) 
    #logger.addHandler(stream_handler)  
    logger.setLevel(logging.INFO)   
    return logger


#log END
#if _LOG_LEVEL ==0:
#        uwsgilog.info( 'S:'+data )
#else:
#        uwsgilog.error('S:'+data)
